package member2;

import java.text.SimpleDateFormat;
import java.util.ArrayList;

import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import javax.swing.JTextArea;
import javax.swing.JLabel;

import Member1.Data6;

public class Output extends JPanel {
	private JScrollPane scrollPane;
	private JTextArea result;
	private JLabel lblNewLabel;

	ArrayList<Data> list;

	/**
	 * Create the panel.
	 */
	public Output(ArrayList list) {
		this.list = list;
		setLayout(null);
		add(getScrollPane());
		prn();
	}

	public void prn() {
		result.setText("전체데이터 건수:" + list.size());
		result.append("\n-----------------------------------------------------------------------------------\n");
		for (int i = 0; i < list.size(); i++) {
			Data d = list.get(i);
			result.append(d.getIrum() + " ");
			result.append(d.getAddress() + " ");
			result.append(d.getAge()+" ");
			result.append(d.getEmail());
			result.append(d.getPhone());
//			SimpleDateFormat sd2 = new SimpleDateFormat("hh:mm:ss a");
//			String str2 = sd2.format(new Date());

//			if(list == null) continue;
//			 String str =
//			 String.format("%-8s %6d %-10s %-10s %-10s",list.irum,list.age,list.address,list.phone,list.email);
//			 result.append(str);
//			 result.append("\n");
			
			
			
			result.append("\n");
		}
	}

	 
	

	private JScrollPane getScrollPane() {
		if (scrollPane == null) {
			scrollPane = new JScrollPane();
			scrollPane.setBounds(12, 10, 426, 280);
			scrollPane.setViewportView(getResult());
			scrollPane.setColumnHeaderView(getLblNewLabel());
		}
		return scrollPane;
	}

	private JTextArea getResult() {
		if (result == null) {
			result = new JTextArea();
		}
		return result;
	}

	private JLabel getLblNewLabel() {
		if (lblNewLabel == null) {
			lblNewLabel = new JLabel(
					"성명    나이      주소          연락처          이메일      입사일");
		}
		return lblNewLabel;
	}
}
